Purpose
The charCodeAt task is used to obtain a Unicode decimal value (UTF-16) for a character at a specific position in a string. UTF-16 is a 16-bit integer between 0 and 65535.
Potential Use Cases
This task is a character-processing method that returns an encoded value at a specific location, rather than the character itself. You could use charCodeAt to perform string handling with characters you cannot type directly using a keyboard.
This task is also useful for working with strings used in objects such as a Text Field, Context Menu or File Reference object. Let's say you have an input form with a text field that requires an email address. Some browsers only look for the @ symbol and other browsers look for a pattern consisting of @ followed by at least one letter and a dot. You could use charCodeAt to build a text validation function in the form control to parse the email address character by character to validate if the entry is formatted correctly.
Properties
Input and output properties are shown below.
| Incoming | Type | Description | 
|---|---|---|
| str | String | Required. The string to get the character code from. | 
| index | Number | Required. The position of the character in strthat you want to return the Unicode value for. An index of the first character is 0, the second character 1, and so on. Ifindexis not a number, it defaults to 0. | 
| Outgoing | Type | Description | 
|---|---|---|
| code | Number | The UTF-16 decimal value that is returned. The task returns NaNif there is no character at the specifiedindex, or if theindexis less than 0. | 
Examples
Example 1
In the IAP examples shown below:
- The reference variable for the incoming - stris statically set to- Hello World!.
- The - indexnumber is 4. 
- Once the workflow is executed, the - codevalue is displayed under the Outgoing tab in Task History, which is accessed from Job Manager.
- The character code - 111is equal to the lowercase letter- "o". 
Example 2
In the IAP examples shown below:
- The reference variable for the incoming - stris statically set to- Hello Krunal Legere.
- The - indexnumber is 5. 
- The character code that returns is - 32, which is equal to a space in the string.